clang-tidy modernize-use-nullptr on gui.
authortsteven4 <tsteven4@gmail.com>
Sun, 3 Mar 2019 17:26:27 +0000 (10:26 -0700)
committertsteven4 <tsteven4@gmail.com>
Sun, 3 Mar 2019 17:26:27 +0000 (10:26 -0700)
gui/formatload.cc
gui/gmapdlg.cc
gui/main.cc
gui/mainwindow.cc
gui/map.cc
gui/optionsdlg.cc
gui/serial_unix.cc
gui/upgrade.cc

index 79b7e2636498b6e49fefdb17aade13cd8b4a1825..fc806cf60d446bfdd503a45bb47372d98f114a6d 100644 (file)
@@ -156,7 +156,7 @@ bool FormatLoad::getFormats(QList<Format>& formatList)
     Format format;
     if (!processFormat(format)) {
       QMessageBox::information
-      (0, appName,
+      (nullptr, appName,
        QObject::tr("Error processing formats from running process \"gpsbabel -^3\" at line %1").arg(lineList[currentLine_]));
     } else {
       formatList << format;
index aec2fec66a190e3de4861ad206cd3d3382d1df4b..c69177ae58b4479da0c0093a265ab0f944f1c243 100644 (file)
@@ -250,7 +250,7 @@ void GMapDialog::itemChangedX(QStandardItem* it)
   else {
     // Individual items, find the right one.
     GpxItem* git = static_cast<GpxItem*>(it->data().value<void*>());
-    if (git != 0) {
+    if (git != nullptr) {
       git->setVisible(show);
       for (int i=0; i<gpx_.getWaypoints().size(); i++) {
         if (&gpx_.getWaypoints()[i] == git) {
index e84f41bb0d1aed96fc2292167ec9da4dc4ac19fa..77762f3a9c12d06dbbe3f981f6b2efd047da74f3 100644 (file)
@@ -63,7 +63,7 @@ int main(int argc, char** argv)
   QCoreApplication::setOrganizationDomain("gpsbabel.org");
   QCoreApplication::setApplicationName("GPSBabel");
 
-  MainWindow mainWindow(0);
+  MainWindow mainWindow(nullptr);
   mainWindow.show();
   app->exec();
 
index 25a4b4d69a7ea5812a2f7fad5be186cc3d5e6942..3ff7fa4afd435c6f058be5c8a4d0bc9951540eca 100644 (file)
@@ -216,7 +216,7 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent)
   }
 
   if (!babelData_.ignoreVersionMismatch_ && babelVersion_ != VERSION) {
-    VersionMismatch vm(0, babelVersion_, QString(VERSION));
+    VersionMismatch vm(nullptr, babelVersion_, QString(VERSION));
 
     vm.exec();
     babelData_.ignoreVersionMismatch_ = vm.neverAgain();
@@ -277,7 +277,7 @@ void MainWindow::createLanguageMenu(void)
 // Called every time, when a menu entry of the language menu is called
 void MainWindow::slotLanguageChanged(QAction* action)
 {
-  if (0 != action) {
+  if (nullptr != action) {
     // load the language dependant on the action content.
     loadLanguage(action->data().toString());
   }
@@ -311,7 +311,7 @@ void MainWindow::loadLanguage(const QString& rLanguage)
 
 void MainWindow::changeEvent(QEvent* event)
 {
-  if (0 != event) {
+  if (nullptr != event) {
     switch (event->type()) {
     // This event is sent if a translator is loaded.
     case QEvent::LanguageChange:
@@ -536,7 +536,7 @@ void MainWindow::browseInputFile()
   }
 
   QStringList userList =
-    QFileDialog::getOpenFileNames(0, tr("Select one or more input files"),
+    QFileDialog::getOpenFileNames(nullptr, tr("Select one or more input files"),
                                   startFile,
                                   filterForFormat(idx));
   if (!userList.empty()) {
@@ -564,7 +564,7 @@ void MainWindow::browseOutputFile()
   }
 
   QString str =
-    QFileDialog::getSaveFileName(0, tr("Output File Name"),
+    QFileDialog::getSaveFileName(nullptr, tr("Output File Name"),
                                  startFile,
                                  filterForFormat(idx));
   if (str.length() != 0) {
@@ -627,7 +627,7 @@ QList<int> MainWindow::outputDeviceFormatIndices()
 void MainWindow::loadFormats()
 {
   if (!FormatLoad().getFormats(formatList_)) {
-    QMessageBox::information(0, QString(appName),
+    QMessageBox::information(nullptr, QString(appName),
                              tr("Error reading format configuration.  "
                                 "Check that the backend program \"gpsbabel\" is properly installed "
                                 "and is in the current PATH\n\n"
@@ -638,7 +638,7 @@ void MainWindow::loadFormats()
       inputDeviceFormatIndices().empty() ||
       outputFileFormatIndices().empty() ||
       outputDeviceFormatIndices().empty()) {
-    QMessageBox::information(0, QString(appName),
+    QMessageBox::information(nullptr, QString(appName),
                              tr("Some file/device formats were not found during initialization.  "
                                 "Check that the backend program \"gpsbabel\" is properly installed "
                                 "and is in the current PATH\n\n"
@@ -786,10 +786,10 @@ void MainWindow::inputOptionButtonClicked()
   int fidx = currentComboFormatIndex(ui_.inputFormatCombo);
   if (formatList_[fidx].getInputOptionsRef()->empty()) {
     QMessageBox::information
-    (0, appName,
+    (nullptr, appName,
      tr("There are no input options for format \"%1\"").arg(formatList_[fidx].getDescription()));
   } else {
-    OptionsDlg optionDlg(0,
+    OptionsDlg optionDlg(nullptr,
                          formatList_[fidx].getName(),
                          formatList_[fidx].getInputOptionsRef(),
                          formatList_[fidx].getHtml());
@@ -805,10 +805,10 @@ void MainWindow::outputOptionButtonClicked()
   int fidx = currentComboFormatIndex(ui_.outputFormatCombo);
   if (formatList_[fidx].getOutputOptionsRef()->empty()) {
     QMessageBox::information
-    (0, appName,
+    (nullptr, appName,
      tr("There are no output options for format \"%1\"").arg(formatList_[fidx].getDescription()));
   } else {
-    OptionsDlg optionDlg(0,
+    OptionsDlg optionDlg(nullptr,
                          formatList_[fidx].getName(),
                          formatList_[fidx].getOutputOptionsRef(),
                          formatList_[fidx].getHtml());
@@ -826,7 +826,7 @@ bool MainWindow::isOkToGo()
   if (!((ui_.xlateWayPtsCk->isChecked() && ui_.xlateWayPtsCk->isEnabled()) ||
         (ui_.xlateRoutesCk->isChecked() && ui_.xlateRoutesCk->isEnabled()) ||
         (ui_.xlateTracksCk->isChecked() && ui_.xlateTracksCk->isEnabled()))) {
-    QMessageBox::information(0, QString(appName), tr("No valid waypoints/routes/tracks translation specified"));
+    QMessageBox::information(nullptr, QString(appName), tr("No valid waypoints/routes/tracks translation specified"));
     return false;
   }
 
@@ -845,18 +845,18 @@ bool MainWindow::isOkToGo()
 
   if ((babelData_.inputType_ == BabelData::fileType_) &&
       (babelData_.inputFileNames_.empty())) {
-    QMessageBox::information(0, QString(appName), tr("No input file specified"));
+    QMessageBox::information(nullptr, QString(appName), tr("No input file specified"));
     return false;
   }
 
   if (babelData_.outputType_ == BabelData::noType_ && babelData_.previewGmap_ == true) {
   }
   if (babelData_.outputType_ == BabelData::noType_ && babelData_.previewGmap_ == false) {
-    QMessageBox::information(0, QString(appName), tr("No valid output specified"));
+    QMessageBox::information(nullptr, QString(appName), tr("No valid output specified"));
     return false;
   } else if (babelData_.outputType_ == BabelData::fileType_ &&
              babelData_.outputFileName_.length() == 0) {
-    QMessageBox::information(0, QString(appName), tr("No output file specified"));
+    QMessageBox::information(nullptr, QString(appName), tr("No output file specified"));
     return false;
   }
   return true;
@@ -866,10 +866,10 @@ bool MainWindow::isOkToGo()
 bool MainWindow::runGpsbabel(const QStringList& args, QString& errorString,
                              QString& outputString)
 {
-  QProcess* proc = new QProcess(0);
+  QProcess* proc = new QProcess(nullptr);
   QString name = "gpsbabel";
   proc->start(name, args);
-  ProcessWaitDialog* waitDlg = new ProcessWaitDialog(0, proc);
+  ProcessWaitDialog* waitDlg = new ProcessWaitDialog(nullptr, proc);
 
   if (proc->state() == QProcess::NotRunning) {
     errorString = QString(tr("Process \"%1\" did not start")).arg(name);
@@ -1031,7 +1031,7 @@ void MainWindow::applyActionX()
     ui_.outputWindow->appendPlainText(tr("Translation successful"));
     if (babelData_.previewGmap_) {
       this->hide();
-      GMapDialog dlg(0, tempName, babelData_.debugLevel_ >=1 ? ui_.outputWindow : 0);
+      GMapDialog dlg(nullptr, tempName, babelData_.debugLevel_ >=1 ? ui_.outputWindow : nullptr);
       dlg.show();
       dlg.exec();
       QFile(tempName).remove();
@@ -1054,7 +1054,7 @@ void MainWindow::closeActionX()
   QDateTime now = QDateTime::currentDateTime();
   if ((babelData_.runCount_ == 1) ||
       ((babelData_.runCount_ > 5) && (babelData_.donateSplashed_.daysTo(now) > 30))) {
-    Donate donate(0);
+    Donate donate(nullptr);
     if (babelData_.donateSplashed_.date() == QDate(2010,1,1)) {
       donate.showNever(false);
     }
@@ -1063,7 +1063,7 @@ void MainWindow::closeActionX()
   }
   saveSettings();
   delete upgrade;
-  upgrade = 0;
+  upgrade = nullptr;
   qApp->exit(0);
 }
 
@@ -1172,7 +1172,7 @@ void MainWindow::resetFormatDefaults()
 //------------------------------------------------------------------------
 void MainWindow::moreOptionButtonClicked()
 {
-  AdvDlg advDlg(0, babelData_.synthShortNames_,
+  AdvDlg advDlg(nullptr, babelData_.synthShortNames_,
                 babelData_.previewGmap_, babelData_.debugLevel_);
   connect(advDlg.formatButton(), SIGNAL(clicked()),
           this, SLOT(resetFormatDefaults()));
@@ -1181,7 +1181,7 @@ void MainWindow::moreOptionButtonClicked()
 //------------------------------------------------------------------------
 void MainWindow::aboutActionX()
 {
-  AboutDlg aboutDlg(0, babelVersion_, QString(appName) + QString(" " VERSION), babelData_.installationUuid_);
+  AboutDlg aboutDlg(nullptr, babelVersion_, QString(appName) + QString(" " VERSION), babelData_.installationUuid_);
   aboutDlg.setWindowTitle(tr("About %1").arg(appName));
   aboutDlg.exec();
 }
@@ -1197,7 +1197,7 @@ void MainWindow::upgradeCheckActionX()
 //------------------------------------------------------------------------
 void MainWindow::preferencesActionX()
 {
-  Preferences preferences(0, formatList_, babelData_);
+  Preferences preferences(nullptr, formatList_, babelData_);
   preferences.exec();
 
   // We may have changed the list of displayed formats.  Resynchronize.
@@ -1213,7 +1213,7 @@ void MainWindow::helpActionX()
 //------------------------------------------------------------------------
 void MainWindow::filtersClicked()
 {
-  FilterDialog dlg(0, filterData_);
+  FilterDialog dlg(nullptr, filterData_);
   dlg.runDialog();
   updateFilterStatus();
 }
@@ -1326,5 +1326,5 @@ QString MainWindow::getFormatNameForExtension(const QString& ext)
       }
     }
   }
-  return 0;
+  return nullptr;
 }
index d4282274f01122cef79df46b513e860b15ddad96..ea9c84ec22d20fb78d3d3a3e43b83e2d6dc5f7ff 100644 (file)
@@ -92,7 +92,7 @@ Map::Map(QWidget* parent,
 
   QString baseFile =  QApplication::applicationDirPath() + "/gmapbase.html";
   if (!QFile(baseFile).exists()) {
-    QMessageBox::critical(0, appName,
+    QMessageBox::critical(nullptr, appName,
                           tr("Missing \"gmapbase.html\" file.  Check installation"));
   } else {
     QString urlStr = "file:///" + baseFile;
@@ -130,7 +130,7 @@ void Map::loadFinishedX(bool f)
 {
   this->logTime("Done initial page load");
   if (!f)
-    QMessageBox::critical(0, appName,
+    QMessageBox::critical(nullptr, appName,
                           tr("Failed to load Google maps base page"));
   else {
     QApplication::processEvents();
index 86563b4cbde957c170d5ccd110ccb6f3f56bc396..546d544344c7853e8ec45645728446aa3531b2e5 100644 (file)
@@ -69,11 +69,11 @@ void FileDlgManager::buttonClicked()
 {
   QString str;
   if (isInFile) {
-    str = QFileDialog::getOpenFileName(0, tr("Select input file"),
+    str = QFileDialog::getOpenFileName(nullptr, tr("Select input file"),
                                        le->text(),
                                        "All Files (*.*)");
   } else {
-    str = QFileDialog::getSaveFileName(0, tr("Select output file"),
+    str = QFileDialog::getSaveFileName(nullptr, tr("Select output file"),
                                        le->text(),
                                        "All Files (*.*)");
   }
@@ -106,7 +106,7 @@ OptionsDlg::OptionsDlg(QWidget* parent,  const QString& fmtName, QList<FormatOpt
     QSpacerItem* horizontalSpacer = new QSpacerItem(0, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
     horizontalLayout->addItem(horizontalSpacer);
 
-    QWidget* w = 0;
+    QWidget* w = nullptr;
     switch (options_[k].getType()) {
     case FormatOption::OPTstring: {
       QLineEdit* lineEdit = new QLineEdit(this);
@@ -135,7 +135,7 @@ OptionsDlg::OptionsDlg(QWidget* parent,  const QString& fmtName, QList<FormatOpt
     case FormatOption::OPTbool:
       // If it was selected before, select it again.
       checkBox->setChecked(options_[k].getSelected());
-      w = 0;
+      w = nullptr;
       break;
 
     case FormatOption::OPTfloat: {
index 7e4d421e72c12bc4656d36436f77355487fdafa0..1fb08db30396dfd222101bd4722e267643e82bd3 100644 (file)
@@ -90,7 +90,7 @@ static const char* deviceNames[] = {
   "/dev/ttyS3",
   "/dev/ttyUSB0",
   "/dev/rfcomm0",
-  0
+  nullptr
 };
 
 void MainWindow::osLoadDeviceNameCombos(QComboBox* box)
index 79444e790e19a5261f50d6e53aeaf0fc897f8ab4..73909c85f1538e24ad4a150822bb966957cb351b 100644 (file)
@@ -49,8 +49,8 @@ static const bool testing = false;
 UpgradeCheck::UpgradeCheck(QWidget* parent, QList<Format>& formatList,
                            BabelData& bd) :
   QObject(parent),
-  manager_(0),
-  replyId_(0),
+  manager_(nullptr),
+  replyId_(nullptr),
   upgradeUrl_(QUrl("http://www.gpsbabel.org/upgrade_check.html")),
   formatList_(formatList),
   updateStatus_(updateUnknown),
@@ -62,11 +62,11 @@ UpgradeCheck::~UpgradeCheck()
 {
   if (replyId_) {
     replyId_->abort();
-    replyId_ = 0;
+    replyId_ = nullptr;
   }
   if (manager_) {
     delete manager_;
-    manager_ = 0;
+    manager_ = nullptr;
   }
 }
 
@@ -172,18 +172,18 @@ UpgradeCheck::updateStatus UpgradeCheck::getStatus()
 void UpgradeCheck::httpRequestFinished(QNetworkReply* reply)
 {
 
-  if (reply == 0) {
+  if (reply == nullptr) {
     babelData_.upgradeErrors_++;
     return;
   } else if (reply != replyId_) {
-    QMessageBox::information(0, tr("HTTP"),
+    QMessageBox::information(nullptr, tr("HTTP"),
                              tr("Unexpected reply."));
   } else if (reply->error() != QNetworkReply::NoError) {
     babelData_.upgradeErrors_++;
-    QMessageBox::information(0, tr("HTTP"),
+    QMessageBox::information(nullptr, tr("HTTP"),
                              tr("Download failed: %1.")
                              .arg(reply->errorString()));
-    replyId_ = 0;
+    replyId_ = nullptr;
     reply->deleteLater();
     return;
   }
@@ -202,7 +202,7 @@ void UpgradeCheck::httpRequestFinished(QNetworkReply* reply)
       // Change the url for the next update check.
       // TOODO: kick off another update check.
       upgradeUrl_ = redirectUrl;
-      replyId_ = 0;
+      replyId_ = nullptr;
       reply->deleteLater();
       return;
     }
@@ -214,11 +214,11 @@ void UpgradeCheck::httpRequestFinished(QNetworkReply* reply)
   }
   if (statusCode != 200) {
     QVariant reason = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute);
-    QMessageBox::information(0, tr("HTTP"),
+    QMessageBox::information(nullptr, tr("HTTP"),
                              tr("Download failed: %1: %2.")
                              .arg(statusCode.toInt())
                              .arg(reason.toString()));
-    replyId_ = 0;
+    replyId_ = nullptr;
     reply->deleteLater();
     return;
   }
@@ -231,12 +231,12 @@ void UpgradeCheck::httpRequestFinished(QNetworkReply* reply)
   QString error_text;
   // This shouldn't ever be seen by a user.
   if (!document.setContent(oresponse, &error_text, &line)) {
-    QMessageBox::critical(0, tr("Error"),
+    QMessageBox::critical(nullptr, tr("Error"),
                           tr("Invalid return data at line %1: %2.")
                           .arg(line)
                           .arg(error_text));
     babelData_.upgradeErrors_++;
-    replyId_ = 0;
+    replyId_ = nullptr;
     reply->deleteLater();
     return;
   }
@@ -312,6 +312,6 @@ void UpgradeCheck::httpRequestFinished(QNetworkReply* reply)
   for (int i = 0; i < formatList_.size(); i++) {
     formatList_[i].zeroUseCounts();
   }
-  replyId_ = 0;
+  replyId_ = nullptr;
   reply->deleteLater();
 }